<template>
  <el-input placeholder="请输入您的待办事项，输入完成后按回车添加。" v-model="newTodo" @keyup.enter="handleTodoAdd" />
</template>

<script setup>
  import { ref } from 'vue';

  const emit = defineEmits(['submit-todo'])
  const newTodo = ref('')
  const handleTodoAdd = () => {
    const todoItem = {
      start: new Date().toLocaleString(),
      detail: newTodo.value,
      completed: false
    }
    emit('submit-todo', todoItem)
    newTodo.value = ''
  }
</script>
